<?php Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl.'/protected/components/widgets/script/cart.js'); ?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'cart-table',
    'dataProvider'=>$itemsProvider,
    'enablePagination'=>true,
    'ajaxUpdate'=>true,
    'emptyText'=>'',
    'showTableOnEmpty'=>false,
    'selectableRows'=>1,
    'selectionChanged'=>'function(id){ location.href="'.Yii::app()->createUrl('catalog/products/view').'&prodId="+$.fn.yiiGridView.getSelection(id);}',
    'columns'=>array(
        array(
            'name'=>Yii::t('base','id'),
            'value'=>function($data){ return $data->id; },
            'sortable'=>true,
            'filter'=>false,
        ),
        array(
            'name'=>Yii::t('base','name'),
            'value'=>function($data){ return $data->name; },
            'sortable'=>true,
            'filter'=>false,
        ),
        array(
            'name'=>Yii::t('shopping/cart','model'),
            'value'=>function($data){ return $data->model; },
            'sortable'=>true,
            'filter'=>false,
        ),
        array(
            'name'=>Yii::t('base','count'),
            'value'=>function($data){ return $data->count; },
            'sortable'=>true,
            'filter'=>false,
        ),
        array(
            'class'=>'CButtonColumn',
            'template'=>'{view}{update}{delete}',
            'htmlOptions'=>array(

            ),
            'buttons'=>array(
                'view'=>array(
                    'label'=>Yii::t('base','show'),
                    'url'=>function($data){ return Yii::app()->createUrl('catalog/products/view',array('prodId'=>$data->id,'count'=>$data->count)); },
                    'options'=>array(
                        'ajax'=>array(
                            'type'=>'POST',
                            'url'=>"js:$(this).attr('href')",
                            'update'=>'#detail-wrapper',
                        ),
                        'onClick'=>'Main.openPopup();',
                    ),
                ),
                'update'=>array(
                    'label'=>Yii::t('base','update'),
                    'url'=>function($data){ return Yii::app()->createUrl("catalog/products/update",array("prodId"=>$data->id)); },
                    'options'=>array(
                        'onClick'=>'viewProduct($(this)); return false;',
                        'data-id'=>Yii::app()->createUrl('catalog/products'),
                    ),
                ),
                'delete'=>array(
                    'label'=>Yii::t('base','remove'),
                    'url'=>function($data){ return Yii::app()->createUrl("catalog/products/removeFromCart",array("prodId"=>$data->id)); },
                    'click'=>'false',
                    'options'=>array(
                        'onClick'=>'Cart.removeFromCart($(this)); return false;',
                        'data-id'=>Yii::app()->createUrl('catalog/products/removeFromCart'),
                    ),
                ),
            ),
        ),
    )
)); ?>